home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11955 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  89 lines

  1. Path: news.ov.com!news
  2. From: glenn@ov.com (Fletcher.Glenn@ov.com)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Please help me
  5. Date: 27 Mar 1996 22:41:02 GMT
  6. Organization: OpenVision
  7. Message-ID: <4jcg5u$noj@spanky.pls.ov.com>
  8. References: <4j6oke$lfk@badger.wmin.ac.uk>
  9. Reply-To: glenn@ov.com
  10. NNTP-Posting-Host: foghorn.pls.ov.com
  11.  
  12. In article lfk@badger.wmin.ac.uk, darec@westminster.ac.uk (Nadarajah Thavaneethan) writes:
  13. >#include <std.h>
  14. >
  15. >void writelines( char[], int );
  16. >        int index;
  17. >
  18. >
  19. >void main(void)
  20. >{
  21. >
  22. >int i;
  23. >char rest[80];
  24. >
  25. >
  26. >    printf("Enter line ");
  27. >    scanf("%s", rest);
  28. >    printf("Enter size of new lines");
  29. >    scanf("%d", i);
  30. >    index =0;
  31. >    writelines(rest, i);
  32. >}
  33. >
  34. >void writelines( char r[], int len)
  35. >{
  36. >int i;
  37. >
  38. >       while (index < 80) {
  39. >     for  (i=0; i<len; i++)
  40. >     {
  41. >
  42. >       putchar(r[index]);
  43. >       putchar('\n');
  44. >       }
  45. >        index++;
  46. >}
  47. >}
  48.  
  49. Reformatting the above routine:
  50.  
  51. void writelines( char r[], int len)
  52. {
  53.     int i;
  54.     
  55.     while (index < 80)
  56.     {
  57.         for (i = 0; i < len; i++)
  58.         {
  59.             putchar(r[index]);
  60.             putchar('\n');
  61.         }
  62.         index++;
  63.     }
  64. }
  65.  
  66. The above routine says: Step forward through the input string and 
  67. for "len" times repeat each character followed by a newline.
  68. Is this what you intended?  Isn't it easier to see when properly formatted?
  69.  
  70.             Fletcher.Glenn@ov.com
  71.  
  72. >
  73. >This program reads a line of data and writes it out as smaller lines
  74. >it doesn't but it should!
  75. >
  76. >please mail me 
  77. >
  78. >darec@westminster.ac.uk
  79. >
  80. >
  81. >Thanks in Advance..
  82. >
  83. >
  84.  
  85.  
  86.  
  87.  
  88.  
  89.